package com.wu;

import java.beans.PropertyChangeSupport;

/**
 * {@link java.util.EventObject} 标准事件监听对象
 * {@link java.util.EventListener} 标准事件监听对象
 */

public class EventDemo {

    public static void main(String[] args) {

        PropertyChangeSupport support = new PropertyChangeSupport(new Person());
        support.addPropertyChangeListener("name",evt -> {

            Person p = (Person) evt.getSource();
            System.out.printf("Person %s ,老值: %s ,新值: %s",p,evt.getOldValue(),evt.getNewValue());
        });

        support.firePropertyChange("name" ,null,"wufei");

    }


}

class Person{

    private String name;

    private String sex;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }
}
